Option Strict On
Option Explicit On 

Imports System
Imports System.Object
Imports System.Collections
Imports Microsoft.VisualBasic.ControlChars

Public Class SngDateTime
    Private sCalDate As String = ""
    Private sTimeOfDay As String = ""

    Property SngDate() As String
        Get
            SngDate = sCalDate
        End Get
        Set(ByVal Value As String)
            sCalDate = Value
        End Set
    End Property

    Property TimeOfDay() As String
        Get
            TimeOfDay = sTimeOfDay
        End Get
        Set(ByVal Value As String)
            sTimeOfDay = Value
        End Set
    End Property

End Class

Public Class GeolAge
    Private sGeoTimeScale As String = ""
    Private sGeoAgeEst As String = ""
    Private sGeoAgeUnc As String = ""
    Private sGeoAgeExp As String = ""
    Private cGeolCite As Collection = New Collection
    Private cGCbLWC As Collection = New Collection
    Private cGCiteLWC As Collection = New Collection

    Property TimeScale() As String
        Get
            TimeScale = sGeoTimeScale
        End Get
        Set(ByVal Value As String)
            sGeoTimeScale = Value
        End Set
    End Property
    Property Estim() As String
        Get
            Estim = sGeoAgeEst
        End Get
        Set(ByVal Value As String)
            sGeoAgeEst = Value
        End Set
    End Property
    Property Uncert() As String
        Get
            Uncert = sGeoAgeUnc
        End Get
        Set(ByVal Value As String)
            sGeoAgeUnc = Value
        End Set
    End Property
    Property Explain() As String
        Get
            Explain = sGeoAgeExp
        End Get
        Set(ByVal Value As String)
            sGeoAgeExp = Value
        End Set
    End Property
    ReadOnly Property GCiteCount() As Integer
        Get
            GCiteCount = cGeolCite.Count
        End Get
    End Property
    ReadOnly Property GCiteFetch(ByVal cIndex As Integer) As CiteInfo
        Get
            If (cIndex > 0 And cIndex <= cGeolCite.Count) Then
                Return CType(cGeolCite(cIndex), CiteInfo)
            Else
                MessageBox.Show("Index out of bounds of collection", "Geologic Citations", MessageBoxButtons.OK, MessageBoxIcon.Error)
            End If
        End Get
    End Property
    ReadOnly Property GCbFetchLWC(ByVal cIndex As Integer) As Boolean
        Get
            If (cIndex > 0 And cIndex <= cGeolCite.Count) Then
                Return CType(cGCbLWC(cIndex), Boolean)
            Else
                MessageBox.Show("Index out of bounds of collection", "Geologic Citations", MessageBoxButtons.OK, MessageBoxIcon.Error)
            End If
        End Get
    End Property
    ReadOnly Property GCiteFetchLWC(ByVal cIndex As Integer) As CiteInfo
        Get
            If (cIndex > 0 And cIndex <= cGeolCite.Count) Then
                Return CType(cGCiteLWC(cIndex), CiteInfo)
            Else
                MessageBox.Show("Index out of bounds of collection", "Geologic Citations", MessageBoxButtons.OK, MessageBoxIcon.Error)
            End If
        End Get
    End Property
    Public Sub GCiteRemove(ByVal value As Integer)
        Dim sErrorText As String = "Attempt to remove citation " & value.ToString & " failed." & CrLf
        If (value < 1) Then
            sErrorText = sErrorText & "Index values must be greater than zero!"
            MessageBox.Show(sErrorText, "Index outside of lower bound", MessageBoxButtons.OK, MessageBoxIcon.Error)
            Return
        End If
        If (value <= cGeolCite.Count) Then
            cGeolCite.Remove(value)
            cGCbLWC.Remove(value)
            cGCiteLWC.Remove(value)
        Else
            sErrorText = sErrorText & "There are only " & cGeolCite.Count.ToString & " citations!"
            MessageBox.Show(sErrorText, "Index value error", MessageBoxButtons.OK, MessageBoxIcon.Error)
        End If
    End Sub
    Public Sub GCiteAdd()
        Dim objCite As New CiteInfo
        Dim bNoLWC As New Boolean
        bNoLWC = False
        cGeolCite.Add(objCite)
        cGCbLWC.Add(bNoLWC)
        cGCiteLWC.Add(objCite)
    End Sub
    Public Sub GCiteUpdate(ByVal objCite As CiteInfo, ByVal curindex As Integer)
        'updates the main citation by inserting the new citation before its earlier version, then removing the outdated version
        cGeolCite.Add(objCite, , curindex)
        cGeolCite.Remove(curindex + 1)
    End Sub
    Public Sub GLWCUpdate(ByVal bLWC As Boolean, ByVal objCite As CiteInfo, ByVal curindex As Integer)
        'updates the larger work citation by inserting the new citation before its earlier version, then removing the outdated version
        'updates the Boolean indicating whether the larger work citation needs to be processed in the same manner
        cGCbLWC.Add(bLWC, , curindex)
        cGCbLWC.Remove(curindex + 1)
        cGCiteLWC.Add(objCite, , curindex)
        cGCiteLWC.Remove(curindex + 1)
    End Sub
End Class
